home *** CD-ROM | disk | FTP | other *** search
- /*
- * TIFF Converter
- *
- * Supports: All methods
- *
- * Reads and writes mulitple TIFF (Tagged Image File Format) pictures from specified
- * input/output streams.
- */
-
- #ifndef __TIFFCONVERT__
- #define __TIFFCONVERT__
-
- #import <Converter.h>
-
- #define TIFF_COMPRESS_METHOD "TiffCompressionMethod"
- #define TIFF_COMPRESS_RATIO "TiffCompressionRatio"
-
- #define CONVERT_ERR_NONE 0
- #define CONVERT_ERR_WARNING 1
- #define CONVERT_ERR_FATAL 2
-
- #define ERROR_NO_ERROR 0
- #define ERROR_UNABLE_TO_OPEN 1
- #define ERROR_PERMISSION_DENIED 2
- #define ERROR_BAD_FORMAT 3
- #define ERROR_TRUNCATED_FILE 4
- #define ERROR_NEEDSWINDOWSERV 5
- #define ERROR_UNABLETOLINK 6
- #define ERROR_UNKNOWN 7
-
- @interface TIF : Converter
- {
- }
-
- /*
- * Initializes the object.
- * Assumes: Nothing
- * Returns: self
- * Results: Sets up default compression and compression ratio parameters.
- * That is, TiffCompressMethod is NX_TIFF_COMPRESSION_NONE, and
- * TiffCompressionRatio is 10.
- */
- - init;
-
- /*
- * Frees anything used by the instance.
- * Assumes: Object is instantiated.
- * Results: It is no longer valid to message the object.
- */
- - free;
-
- /*
- * Reads the tiff from stream. This can read any TIFF format that NXBitmapImageRep can.
- * Assumes: The object has been instantiated, stream is an valid stream opened for at least
- * reading. Sender is the id of whatever object is calling the converter.
- * Returns: id of an NXBitmapImageRep or nil if the image was unable to be read.
- */
- - readFromStream: (NXStream *)stream from: sender;
-
- /*
- * Write the image id to stream.
- * Assumes: Object has been instantiated. At times, it's best to have used a call to the
- * save panel first, since this can set internal variables, but it's not necessary.
- * stream should be a valid NXStream opened for at least writing. Sender should
- * be the id of the caller. id is a NXBitmapImageRep, or something that responds
- * to all the message of the NXBitmapImageRep.
- * Returns: YES if the image was sucessfully writing, otherwise it returns NO.
- */
- - (BOOL)write: (id)image toStream: (NXStream *)stream from: sender;
-
- /*
- * Similar to readFromStream but will read multiple TIFF's from a stream, when present.
- * Assumes: Object instantiated. stream valid for reading. sender is id of caller.
- * Returns: id of an NXImage or nil if unable to read the image. It should return a single
- * image in the least, even for formats that don't support multiple images.
- */
- - readAllFromStream: (NXStream *)stream from: sender;
-
- /*
- * Reverses the process of read all.
- * Assumes: Object instantiates. id is to an NXImage or something that responds to all of
- * NXImage's methods. stream is valid for writing. This should always attempt
- * to write at least one image to disk (the first usually) even for formats that
- * don't support multiple images.
- * Returns: YES if the image is sucessfully written to disk.
- */
- - (BOOL)writeAll: (id)image toStream: (NXStream *)stream;
-
- /*
- * Creates and lays out a custom view that allows the user to set compression method
- * and ratio.
- * Assumes: Object instantiated and the window server is running. width should be the
- * maximum width the custom view can be.
- * Returns: id of a parent view or nil if this object doesn't use one.
- */
- - customSaveView: (int)width;
-
- /*
- * This is very similar to customSaveView, however, it is used to set parameters for
- * the run time loading of images. This object does not support input custom views.
- * Assumes: Object instantiated and the window server is running. width should be the
- * maximum width the custom view can be.
- * Returns: id of a parent view or nil if this object doesn't use one.
- */
- - customOpenView: (int)width;
-
- /*
- * Returns the name of the file format.
- * Assumes: Object has been instantiated.
- * Returns: A pointer to a string. The caller should always use something like strcpy to
- * get a copy of the string, since it's life is only guaranteed for the life of the
- * object. The returned string is "Tagged Image File Format (TIFF)".
- */
- - (char *)getFormatName;
-
- /*
- * This can be used to set the compression method and ratio. It will respond to both
- * TIFF_COMPRESS_METHOD and TIFF_COMPRESS_RATIO. With
- * TIFF_COMPRESS_METHOD, the pointer should point to and int definded as one
- * of the compression methods in appkit/tiff.h. With TIFF_COMPRESS_RATIO the
- * pointer should point to a float ranging from 1 to 255. 1 is little compress 255 too much.
- * Assumes: The converter is instantiated, parameter is a NULL terminated character
- * string, and ptr is a pointer to the data type. This is determined by patameter.
- * Returns: YES if the value was set, NO if the setting failed for any reason.
- */
- - (BOOL)setCustomParameter: (const char *)parameter withValue: (void *)ptr;
-
- /*
- * Returns values of the custom paramters. See discussion in setCustomParameter for
- * parameter types.
- * Assumes: The converter is instantiated and parameter is a NULL terminater char-
- * acter string.
- * Returns: A pointer to the parameter (type depends on return value) or nil if the
- * parameter is not understood. Returned values should be copied.
- */
- - (void *)getCustomParameter: (const char *)parameter;
-
- /*
- * Returns a string with copyright information, name of the author, where the author
- * can be reached, etc. This should only be a couple of lines, so keep it short and
- * sweet. An example might be:
- * "My Image Format Converter\nby Joe Programmer\nCopyright R'N'R Software\n ...
- * ... email bugs to jprogramm@system.there.edu"
- * Assumes: Converter linked and instantiated.
- * Returns: A pointer to a null terminated string. This string must be non volatile for
- * the life of the converter. Ie, as long as the programmer keeps a converter
- * linked, the pointer should be valid.
- */
- - (char *)copyrightNotice;
-
- /*
- * Returns the current error state of the converter.
- * Assumes: Converter has been instantiated.
- * Returns: 0 = CONVERT_ERR_NONE Signals no error
- * 1 = CONVERT_ERR_WARNING Signals action taken, but not one expected.
- * 2 = CONVERT_ERR_FATAL Signals no action taken.
- */
- - (int)errorState;
-
- /*
- * Returns an int describing the current error message.
- * Assumes: Converter instantiated.
- * Returns: An int describing the error type. See defines for integers returned.
- */
- - (int)errorMessage;
-
- /*
- * This provides support for non standard error messages. It's preferable for programmers
- * to avoid this message, but in special cases where you need to express something unique,
- * it is appropiate. Just remember, that the use of this message disables multilingual
- * support.
- * Assumes: Converter Instantiated
- * Returns: NULL terminated string describing the error.
- */
- - (char *)errorStringMessage;
-
- /*
- * This method returns YES if the converter requires the window server. Ideally, converters
- * should not depend on the window server, but sometimes this cannot be avoided. For
- * example, a programmer wouldn't be expect to write a PostScript interpreter just to read
- * in eps files. Note, however, that returning YES will result in the converter not working
- * with command line versions of applications.
- * Assumes: Converter Instantiated
- * Returns: YES is window server is needed, NO otherwise.
- */
- - (BOOL)needsWindowServer;
-
- /*
- * Returns a string in the form <major version>.<minor version>. This is used by
- * the calling program to see what level or protocol the object will respond to.
- * Assumes: Converter instantiated.
- * Returns: A null terminated string in the form <major version>.<minor version>.
- * For example, 1.0.
- */
- - (char *)protocolVersion;
-
- @end
-
- #endif
-